<?php

class Params extends ArrayObject {
	public function __construct($array = array()) {
		foreach ($array as $key => $value) {
			if (is_array($value)) $array[$key] = new Params($value);
		}
		parent::__construct($array, ArrayObject::ARRAY_AS_PROPS);
	}

	public function offsetGet($index) {
		return isset($this[$index]) ? parent::offsetGet($index) : null;
	}

	# debug only
	public function __toString() {
		return var_export(get_object_vars($this), true);
	}

  public function set($key, $value) {
    $this->$key = $value;
    return $this;
  }
}
